package com.store.practice.controller;

import com.store.practice.common.api.CommonResult;
import com.store.practice.service.StoreOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Api(tags = "OrderController",description = "预约管理")
@RestController
@RequestMapping("/storeOrder")
public class OrderController {
    @Autowired
    private StoreOrderService storeOrderService;

    @ApiOperation("展示预约信息")
    @GetMapping("/getOrder")
    public CommonResult getOrder(Integer storeId){
        List<Map> result = storeOrderService.getOrder(storeId);
        if (result==null){
            return CommonResult.failed();
        }
        return CommonResult.success(result);
    }

    @ApiOperation("门店操作预约状态")
    @PostMapping("/update")
    public CommonResult update(Integer id,Integer param){
        int i = storeOrderService.update(id, param);
        if (i>0){
            return CommonResult.success(i);
        }
        return CommonResult.failed();
    }
}
